<?php

namespace app\admin\model;

use think\Model;


class Socialization extends Model
{

    

    

    // 表名
    protected $name = 'socialization';
    

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'first_registration_time_text',
        'second_registration_time_text',
        'final_confirm_time_text',
        'reward_application_time_text',
        'create_time_text',
        'update_time_text'
    ];
    

    



    public function getFirstRegistrationTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['first_registration_time']) ? $data['first_registration_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }


    public function getSecondRegistrationTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['second_registration_time']) ? $data['second_registration_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }


    public function getFinalConfirmTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['final_confirm_time']) ? $data['final_confirm_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }


    public function getRewardApplicationTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['reward_application_time']) ? $data['reward_application_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }


    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d", $value) : $value;
    }

    protected function setFirstRegistrationTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setSecondRegistrationTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setFinalConfirmTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setRewardApplicationTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
